home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / gs3.53 / ps2ai.ps < prev    next >
Text File  |  1996-01-10  |  23KB  |  543 lines

  1. %!
  2. %    Copyright (C) 1994 Aladdin Enterprises.  All rights reserved.
  3. %
  4. % This file is part of Ghostscript.
  5. %
  6. % Ghostscript is distributed in the hope that it will be useful, but
  7. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. % to anyone for the consequences of using it or for whether it serves any
  9. % particular purpose or works at all, unless he says so in writing.  Refer
  10. % to the Ghostscript General Public License for full details.
  11. %
  12. % Everyone is granted permission to copy, modify and redistribute
  13. % Ghostscript, but only under the conditions described in the Ghostscript
  14. % General Public License.  A copy of this license is supposed to have been
  15. % given to you along with Ghostscript so you can know your rights and
  16. % responsibilities.  It should be in a file named COPYING.  Among other
  17. % things, the copyright notice and this notice must be preserved on all
  18. % copies.
  19.  
  20. %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  21. %
  22. %   ps2ai.ps - a postscript to editable adobe illustrator file filter
  23. %
  24. /vers {2.13} def                  %                    April 25, 1994  
  25. %
  26. %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  27. %
  28. % needs a postscript level 2 interpreter, like gnu ghostscript, to work
  29. %
  30. %      Usage:   gs -q -dNODISPLAY ps2ai.ps file.ps > file.aips
  31. %                              or (see below)
  32. %               gs -q -dNODISPLAY ps2ai.ps file.ps
  33. %                              or
  34. %               cat ps2ai.ps file.ps | lpr  (then look in log file)
  35. %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  36. %                            Options
  37. %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  38. %   Output Options: directly to a file or standard out
  39. %
  40. /jout false def            % true=file  false=stdout (default=false)
  41. /joutput (ps2ai.out.aips) def      % Name of Output file
  42. %
  43. %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  44. %
  45. %              Other Options
  46. %
  47. /jtxt3 true def           % output text in AI3 form (false=ai88)
  48.                           % for coreldraw/photoshop readable output
  49. /joutln false def         % use font outline  instead of font
  50. /jerr false def            % use error handling (ie die gracefully)
  51. /jbiterr false def         % attempt to handle bitmap fonts (kludge)
  52. /jMacGS false def         % true if using MacGS (not fully implemented yet)
  53. /jMacfix true def         % convert filled boxes to lines (only usefull with
  54.                           % laserwriter 8 postscript input)
  55. %
  56. %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  57. %                    No options below here
  58. %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  59. %
  60. %         - Notes -
  61. %  ai uses cmykcolor, so level 1 interpreters don't work
  62. %  ai doesn't use image/imagemask - so bitmaps don't work correctly
  63. %  the output file has a header so it is viewable/printable/reconvertable
  64. %
  65. % Comments, suggestions, bug-fixes, etc send to:
  66. %
  67. %        Jason Olszewski (olszewsk@splash.princeton.edu)
  68. %
  69. % anonymous ftp: toby.princeton.edu /pub/olszewsk/ps2ai.ps
  70. %       URL ftp://toby.princeton.edu/pub/olszewsk
  71. %
  72. %         - Fix History -
  73. %  2.13 check for bitmap fonts, work better with TeX,WinPS,etc
  74. %  2.12 fixed initclip to US letter size page
  75. %  2.11 added header support for *u/*U compound paths
  76. %  2.1  option of font outline instead of text(gwhite@trevnx.bio.dfo.ca)
  77. %  2.0  major change to complex path handling
  78. %  1.9  fixed text leaking ascii (,),\
  79. %  1.85 added default font to handle no setfont (Courier)
  80. %  1.84 added even-odd fill/clip (D)
  81. %  1.83 undefined PPD PageSize printer specific info
  82. %  1.82 added kludge to save clipping status through a restore
  83. %  1.81 added custom color/gray support to header (x/X, g/G)
  84. %  1.8  added newpath if clippath is not consumed correctly(amiga)
  85. %  1.79 eliminated scientific notation of numbers less than 0.0001
  86. %  1.78 fixed transposed h & H
  87. %  1.77 made laserwriter 8 fixes optional
  88. %  1.76 added margin fix for unix AI (brown@wi.extrel.com)
  89. %  1.75 added kludge to handle bitmap font errors (TeX, Windows.ps)
  90. %  1.74 made grestore a little smarter
  91. %  1.73 included header handle encoded fontname (/_fontname)
  92. %  1.72 fixed problem with restore/clip info - (not enough Qs problem)
  93. %  1.71 filter font names to remove previous encoding (|,_,etc)
  94. %  1.7  change text format to AI3, works better with PS & CD
  95. %  1.67 deal with weird makefonts 
  96. %  1.66 handle to many bad stroke/fills (s s s w/o paths)
  97. %  1.65 more useable with non-gs interpreters (defaultmatrix fix)
  98. %  1.64 fixed "smart grestore" repeat bug
  99. %  1.63 fixed ashow/awidthshow bug
  100. %  1.62 check if cmykcolor is understood otherwise rgb
  101. %  1.61 made grestore smarter (only print if different)
  102. %  1.6  add better compatibility to CorelDraw and PhotoShop
  103. %  1.53 make it more gs-backward compatible (clarke@lsl.co.uk)
  104. %  1.52 handle clipping paths a little better (Posted)
  105. %  1.51 improve mac lw8 output (lines instead of filled boxes)
  106. %  1.5 handle some level 2 stuff (mac lw8)
  107. %  1.4 fixed scaling of linewidth and dash
  108. %  1.31 made trailer more AI88 friendly
  109. %  1.3 add ablity to output to file directly
  110. %  1.21 print matrix cleaner
  111. %  1.2 fix rotated fonts, thanks to G.Cameron (g.cameron@biomed.abdn.ac.uk)
  112. %  1.1 fix stroke/fill color difference (k vs K)
  113. %  1.0 posted to comp.lang.postscript
  114. %
  115. %         - To Do List -
  116. %  find real %%BoundingBox: llx lly urx ury
  117. %  make MacGS friendly (line-endings)
  118. %  handle eps w/o showpage:(append to end)
  119. %  write out image data to external file
  120. %
  121. %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  122. %                  Nothing of Interest below here
  123. %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  124. matrix identmatrix setmatrix %   make ctm [1 0 0 1 0 0]
  125. /oldgsave {} def /oldgrestore {} def
  126. /initgraphics {} def /initmatrix {} def 
  127. % undefine PPD PageSizes to be more printer independant
  128. /letter {} def /legal {} def /a4 {} def /b5 {} def /lettersmall {} def
  129. /setpagedevice { pop } def % for level 2 PPD PageSizes
  130. /Courier findfont 12 scalefont setfont % handle no setfont
  131. /initclip {0 0 moveto 0 792 lineto 612 792 lineto 612 0 lineto closepath
  132.            clip newpath } def
  133. /xdef {exch def} def
  134. /trx {transform exch} def
  135. /cbdef {cvx bind def} def
  136. /jltz {dup abs 0.0001 lt {pop 0} if} def % get rid of scientific notation bug
  137. /clstate false def        % closepath state
  138. /dpth false def           % destroy path (ie newpath)
  139. /fclp false def           % first paint after clip
  140. /kscl {1.0} def           % default current scale X-factor
  141. /gcnt {1} def             % graphics state counter
  142. /spth {1} def             % multiple paths on stack
  143. /jeol (\n) def            % default end-of-line
  144. /jnump {0} def            % number of paths on stack
  145. /jx {0} def /jy {0} def /j_ax {0} def
  146. /j3ftxt true def
  147. /clarry 10 array def
  148. 0 1 9 {clarry exch false put} for % initilize no clipping path
  149. %
  150. % handle cmyk color on level 1 interpreters
  151. /setcmykcolor where {pop}
  152.  {/setcmykcolor {
  153.    /blk exch def /yel exch def /mag exch def /cyan exch def
  154.    /ccomp {add dup 1 gt {pop 1} if} def
  155.    /red {1 cyan blk ccomp sub} def
  156.    /green {1 mag blk ccomp sub} def
  157.    /blue {1 yel blk ccomp sub} def
  158.    red green blue setrgbcolor
  159.   } def
  160. } ifelse
  161. /currentcmykcolor where {pop}
  162.  {/currentcmykcolor {
  163.    currentrgbcolor /bval xdef /gval xdef /rval xdef
  164.    /rawC 1 rval sub def /rawM 1 gval sub def /rawY 1 bval sub def
  165.    rawC rawM ge { rawY rawM ge { /blk rawM def} if } if
  166.    rawC rawY ge { rawM rawY ge { /blk rawY def} if } if
  167.    rawY rawC ge { rawM rawC ge { /blk rawC def} if } if
  168.    rawY rawC eq { rawM rawC eq { /blk rawC def} if } if
  169.    /cyan  rawC blk sub  def
  170.    /mag  rawM blk sub  def
  171.    /yel  rawY blk sub  def
  172.    /blk blk def
  173.    cyan mag yel blk
  174.   } def
  175. } ifelse
  176. % If using Mac Ghostscript 
  177. jMacGS { 
  178. %        /jeol {(\r) jp} def
  179.         /jout true def
  180.         (%%Note: Loading ps2ai.ps\n) print
  181.        } if
  182. /jstr 40 string def
  183. jout {joutput (w) file /joutput xdef} if
  184. %
  185. %              Output
  186. %
  187. jout {/jp { joutput exch writestring } bind def }{/jp {print}bind def} ifelse
  188. /jpnum {jltz ( ) jp =string cvs jp } bind def
  189. /jpmat { dup /jarry exch def length 1 sub /j_num exch def
  190.  (\[) jp 0 1 j_num {jarry exch get jpnum} for (\]) jp } def
  191. %
  192. %              Stack to Paths converters
  193. %
  194. /ckpnt { % check which paint and clipping to use
  195.    dpth {  % if there are multiple paths on the stack
  196.   clarry gcnt get fclp and {clstate {(h W\n) jp }{(H W\n) jp } ifelse} if
  197.   spth 0 eq {clstate {(n\n) jp }{(N\n) jp } ifelse} if
  198.   spth 1 eq {clstate {(s\n) jp }{(S\n) jp } ifelse} if
  199.   spth 2 eq {clstate {(f\n) jp }{(F\n) jp } ifelse} if
  200.      } if
  201. } def
  202. /jpm {
  203.   ckpnt
  204.   /dpth true def
  205.   transform 2 copy /yst xdef /xst xdef exch jpnum jpnum ( m\n) jp } bind def
  206. /jpl { trx jpnum jpnum ( l\n) jp } bind def
  207. /jpc {  6 4 roll trx jpnum jpnum 4 2 roll trx jpnum jpnum trx
  208.     jpnum jpnum ( c\n) jp } bind def
  209. /jpp {xst jpnum yst jpnum ( l\n) jp /clstate true def} def
  210. /cntpaths { % count paths on stack
  211.   oldgsave
  212.   {pop pop /jnump jnump 1 add def} {pop pop} {6 {pop} repeat}{} pathforall
  213.   oldgrestore
  214. } def
  215. /ppforall {
  216.  cntpaths % find out how many paths are on the stack
  217.  jnump 1 gt { (*u\n) jp } if
  218.  {jpm}{jpl}{jpc}{jpp} pathforall 
  219.   ckpnt
  220.  jnump 1 gt { (*U\n) jp } if
  221.  /jnump 0 def /clstate false def /dpth false def /fclp false def
  222.   oldnewpath
  223. } bind def
  224. %
  225. %              Painting Operators
  226. %
  227. /oldnewpath [/newpath load] cbdef
  228. /newpath { (\n) jp /spth 0 def ppforall} def 
  229. /stroke { (\n) jp /spth 1 def ppforall } def 
  230. /fill   {(\n) jp /spth 2 def ppforall } def 
  231. /eofill {(1 D\n) jp fill (0 D\n) jp} def
  232. /clip {clarry gcnt get {(Q\nq\n) jp}{(q\n) jp} ifelse 
  233.                    /fclp true def clarry gcnt true put} def
  234. /eoclip {(1 D\n) jp clip (0 D\n) jp} def
  235. %
  236. %               Text Operators
  237. %
  238. /oldshow [/show load] cbdef
  239. /curpt {stringwidth pop jx add jy} def 
  240. /jNN {dup 0 eq {pop oldgsave currentfont /FontMatrix get setmatrix kscl
  241.                 oldgrestore} if
  242. } def
  243. /curftmatrix {
  244.  currentfont /FontMatrix get dup 0 get jNN abs /norm exch def 
  245.  dup 0 get norm div exch dup
  246.  1 get norm div exch dup 2 get norm div exch dup 3 get norm div exch dup
  247.  4 get exch 5 get 6 array astore matrix currentmatrix matrix concatmatrix
  248. } def
  249. % AI does not support negitive font sizes
  250. /curftsize {currentfont /FontMatrix get 0 get jNN abs 1000 mul} def
  251. /hstr (X) def
  252. /vbar (|) 0 get def /undsc (_) 0 get def
  253. /ftnamefix { % handle font names with |,_ (previously encoded)
  254. jstr cvs
  255. { %forall
  256.         dup vbar eq {pop}{ %ifelse
  257.             dup undsc eq {pop}{ %ifelse
  258.                     hstr exch 0 exch put hstr jp
  259.             } ifelse
  260.         } ifelse
  261.    } forall   flush
  262. } bind def
  263. %/curftname {currentfont /FontName get ftnamefix}def
  264. /curftname { currentfont /FontName known {currentfont /FontName get}
  265.            { (Times-Roman)} ifelse ftnamefix } def
  266. /lftpar (\() 0 get def
  267. /rhtpar (\)) 0 get def
  268. /bckslsh (\\) 0 get def
  269. /handft { % handle strings with (,),\
  270.    (\() jp
  271.    { %forall
  272.         dup lftpar eq { (\\\() jp }{ %ifelse
  273.             dup rhtpar eq { (\\\)) jp }{ %ifelse
  274.                 dup bckslsh eq { (\\\\) jp }{ %ifelse
  275.                     hstr exch 0 exch put hstr jp
  276.                 } ifelse
  277.             } ifelse
  278.         } ifelse
  279.    } forall (\)) jp flush
  280. } bind def
  281. % AI 3 text format pieces
  282. jtxt3 {
  283. /j3txt { j3ftxt {(0 Ts 100 Tz 0 Tt 0 TA 0 0 5 TC 100 100 200 TW 0 0 0 Ti\n) jp
  284.                 (0 Ta 0 Tq 0 0 TI 0 Tc 0 Tw\n) jp} if } def
  285. /show {oldgsave  (0 To\n) jp 
  286.   currentpoint 2 copy /jy exch def /jx exch def translate 
  287.   curftmatrix /jitm exch def
  288.   0 1 5 {jitm exch get jpnum} for ( 0 Tp\n) jp (TP\n) jp
  289.   (0 Tr\n) jp (\/_) jp curftname  curftsize jpnum ( Tf\n) jp
  290.   (0) jp j_ax  curftsize div 100 mul jpnum ( 100 TC\n) jp %  percent(?)
  291.   dup curpt moveto mark exch handft ( Tx\n) jp (TO\n) jp /j3ftxt false def
  292.   cleartomark currentpoint oldgrestore moveto
  293. } def  
  294. /ashow {exch pop exch /j_ax exch def show /j_ax {0} def } def
  295.  {
  296. /show {oldgsave (u\n) jp currentpoint 2 copy /jy exch def /jx exch def translate
  297.   (\/) jp curftname jstr cvs jp
  298.   curftsize dup jpnum  jpnum ( 0 0 z\n) jp
  299.   curftmatrix jpmat ( e\n) jp
  300.   dup curpt moveto mark exch handft ( t T U\n) jp
  301.   cleartomark currentpoint oldgrestore moveto} def
  302. /ashow {oldgsave (u\n) jp currentpoint translate (\/) jp curftname jstr cvs jp
  303.   curftsize dup jpnum jpnum  exch kscl mul jpnum ( 0 z\n) jp
  304.   curftmatrix jpmat ( e\n) jp dup curpt moveto mark exch handft
  305.   ( t T U\n) jp cleartomark currentpoint oldgrestore moveto} def
  306. } ifelse
  307. /widthshow { show pop pop pop} def
  308. /awidthshow {ashow pop pop pop} def
  309. /kshow {show pop} def
  310. %/show {true charpath fill} bind def   % get outline of charactor
  311. joutln {/show { true charpath currentpoint 
  312.      /jy exch def /jx exch def fill jx jy moveto} bind def} if
  313. %/show {oldshow} def    % do nothing different
  314. %
  315. %               Color Operators
  316. %
  317. /oldsetcmykcolor [/setcmykcolor load] cbdef
  318. /setcmykcolor {oldsetcmykcolor 
  319. currentcmykcolor 4 -1 roll jpnum 3 -1 roll jpnum 2 -1 roll jpnum jpnum ( k\n) jp
  320. currentcmykcolor 4 -1 roll jpnum 3 -1 roll jpnum 2 -1 roll jpnum jpnum ( K\n) jp
  321.  } def
  322. /oldsetgray [/setgray load] cbdef
  323. /setgray {0 0 0 4 -1 roll 1 exch sub setcmykcolor} def
  324. /oldsethsbcolor [/sethsbcolor load] cbdef
  325. /sethsbcolor {oldsethsbcolor currentcmykcolor setcmykcolor} def
  326. /oldsetrgbcolor [/setrgbcolor load] cbdef
  327. /setrgbcolor {oldsetrgbcolor currentrgbcolor /bval xdef /gval xdef /rval xdef
  328.  /rawC 1 rval sub def /rawM 1 gval sub def /rawY 1 bval sub def
  329.  rawC rawM ge { rawY rawM ge { /blk rawM def} if } if
  330.  rawC rawY ge { rawM rawY ge { /blk rawY def} if } if
  331.  rawY rawC ge { rawM rawC ge { /blk rawC def} if } if
  332.  rawY rawC eq { rawM rawC eq { /blk rawC def} if } if
  333.  /cyan  rawC blk sub  def
  334.  /mag  rawM blk sub  def
  335.  /yel  rawY blk sub  def
  336.  /blk blk def
  337.  cyan mag yel blk setcmykcolor } def
  338. %
  339. %                State Operators
  340. %
  341. /oldsetlinewidth [/setlinewidth load] cbdef
  342. /setlinewidth {kscl abs mul jltz  oldsetlinewidth
  343.  currentlinewidth jpnum ( w\n) jp } def
  344. /oldsetlinecap [/setlinecap load] cbdef
  345. /setlinecap {dup oldsetlinecap jpnum ( J\n) jp} def
  346. /oldsetlinejoin [/setlinejoin load] cbdef
  347. /setlinejoin {dup oldsetlinejoin jpnum ( j\n) jp} def
  348. /oldsetmiterlimit [/setmiterlimit load] cbdef
  349. /setmiterlimit {dup oldsetmiterlimit jpnum ( M\n) jp}def
  350. /oldsetdash [/setdash load] cbdef
  351. /setdash {exch [ exch {kscl abs mul} forall ] exch kscl abs mul oldsetdash
  352.   currentdash exch jpmat jpnum ( d\n) jp } def
  353. /oldsetflat [/setflat load] cbdef
  354. /setflat {dup oldsetflat jpnum ( i\n) jp } def
  355. %
  356. %                More State Operators
  357. %
  358. /kscl { % use just the x scale factor
  359.  oldgsave
  360.  matrix currentmatrix /jctm exch def
  361.  jctm 4 0 put jctm 5 0 put jctm setmatrix
  362.  1 0 moveto currentpoint transform
  363.  dup mul exch dup mul add sqrt 10000 mul round 10000 div
  364.  oldgrestore
  365. } def
  366. /currentstate {currentcmykcolor setcmykcolor
  367.  currentflat jpnum ( i) jp currentlinecap jpnum ( J) jp
  368.  currentlinejoin jpnum ( j) jp currentlinewidth jpnum ( w) jp
  369.  currentmiterlimit jpnum ( M ) jp currentdash exch jpmat jpnum ( d\n) jp 
  370. } def
  371. /jdifG {
  372.  currentcmykcolor /jok xdef /joy xdef /jom xdef /joc xdef
  373.  currentflat /jof xdef currentlinecap /jolc xdef currentlinejoin /jolj xdef
  374.  currentlinewidth /jolw xdef currentmiterlimit /joml xdef
  375.  currentdash /jood xdef /joad xdef
  376.  oldgrestore
  377.  currentcmykcolor /jnk xdef /jny xdef /jnm xdef /jnc xdef
  378.  currentflat /jnf xdef currentlinecap /jnlc xdef currentlinejoin /jnlj xdef
  379.  currentlinewidth /jnlw xdef currentmiterlimit /jnml xdef
  380.  currentdash /jnod xdef /jnad xdef
  381.  % compare old gstate to new gstate
  382.  joc jnc ne jom jnm ne joy jny ne jok jnk ne
  383.  jof jnf ne jolc jnlc ne jolj jnlj ne jolw jnlw ne joml jnml ne 
  384.  false joad {true exit} forall {pop pop true}{false} ifelse
  385.  false jnad {true exit} forall {pop pop true}{false} ifelse ne
  386.  jood jnod ne 10 {or} repeat {currentstate} if
  387. } def
  388. /oldgsave [/gsave load] cbdef
  389. /gsave {oldgsave /gcnt gcnt 1 add def } def % clarry gcnt false put} def
  390. %  (%%Note:gsave ) jp gcnt jpnum (\n) jp} def
  391. /oldgrestore [/grestore load] cbdef
  392. /grestore {dpth {newpath} if clarry gcnt get {(Q\n) jp clarry gcnt false put} if 
  393.  jdifG /gcnt gcnt 1 sub def } def
  394. % oldgrestore currentstate } def
  395. % (%%Note:grestore ) jp gcnt 1 add jpnum (\n) jp} def
  396. /oldrestore [/restore load] cbdef
  397. % a kludgy way of saving the clipping path status information
  398. /restore {clarry aload pop 11 -1 roll oldrestore clarry astore pop} def
  399. /showpage {  0 1 9 {clarry exch get {(Q\n) jp} if } for
  400.  (%%Note: If Error, make sure there are matched pairs of 'q's and 'Q's\n) jp
  401.  (%%Note: in the file. Add 'Q's before '%%Trailer' until equal\n) jp
  402.  (%%Trailer\n) jp
  403.  jtxt3 {(Adobe_IllustratorA_AI3 /terminate get exec\n) jp
  404.         (Adobe_typography_AI3 /terminate get exec\n) jp
  405.         (Adobe_customcolor /terminate get exec\n) jp
  406.         (Adobe_cshow /terminate get exec\n) jp
  407.         (Adobe_cmykcolor /terminate get exec\n) jp
  408.         (Adobe_packedarray /terminate get exec\n) jp
  409. }{
  410.         (Adobe_Illustrator881 /terminate get exec\n) jp
  411.         (Adobe_customcolor /terminate get exec\n) jp
  412.         (Adobe_cshow /terminate get exec\n) jp
  413.         (Adobe_cmykcolor /terminate get exec\n) jp
  414.         (Adobe_packedarray /terminate get exec\n) jp 
  415.        } ifelse
  416. ( showpage\n%EOF\n%%EndDocument\n) jp
  417.  jout {joutput closefile} if jMacGS not {quit} if /j3ftxt true def } def 
  418. %
  419. %                Error handling
  420. %
  421. errordict begin
  422. % Attempt to handle the error caused by bitmap fonts (TeX,Windows.ps,etc)
  423. % this is a big-time kludge
  424. jbiterr {
  425.  /undefined {pop pop (Times-Roman)} def
  426.  /typecheck {pop pop} def
  427. } if
  428. jerr {
  429.  /handleerror {
  430.   (%%Note: ps2ai error, aborting rest of conversion\n) jp showpage
  431.  } def
  432. } if
  433. end
  434. %
  435. %                Mac LW 8 improvements
  436. %
  437. /jmacimp { % stroked line instead of thin filled boxes
  438.  /@a {  3 -1 roll 2 div dup 3 -1 roll add exch 3 -1 roll add exch moveto
  439.       3 -1 roll 2 div dup 3 -1 roll add exch 3 -1 roll exch sub exch lineto
  440.       abs setlinewidth  stroke pop pop} def
  441.  /@b { 3 -1 roll 2 div dup 3 -1 roll add exch 3 -1 roll add exch moveto
  442.       pop
  443.       3 -1 roll 2 div dup 3 -1 roll add exch 3 -1 roll add exch lineto
  444.       abs setlinewidth  stroke} def
  445.  /endp {showpage pm restore} def % because the restore stops clean up
  446. } def
  447. %
  448. %                Handle (some) PS Level 2
  449. %
  450. /rectstroke { 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto
  451.   closepath stroke} def
  452. /rectfill { 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto
  453.   fill } def
  454. /rectclip { 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto
  455.   closepath clip newpath jMacfix {jmacimp} if } def
  456. %
  457. % Add a header prolog to the output file so it is still view/print-able
  458. %
  459. (%!PS-Adobe-2.0 EPSF-1.2\n%%BoundingBox: 0 0 612 792\n) jp
  460. (%%Title: Adobe Illustator 3 Editable Document\n) jp
  461. (%%Creator: ps2ai.ps vers.) jp vers jpnum ( \(C\) 1993-94 Jason Olszewski\n) jp
  462. (%%TemplateBox: 0 0 612 792\n) jp
  463. jtxt3 {(%%AI3_Margin:0 0 0 0\n) jp } if
  464. (%%EndComments\n) jp
  465. (%%BeginProlog\n) jp
  466. (/m {moveto} def /l {lineto} def /c {curveto} def\n) jp
  467. (/S {stroke} def /F {fill} def\n) jp
  468. (/s {closepath S} def /f {closepath F} def\n) jp
  469. (/q {gsave} def /Q {grestore} def /W {clip} def /k {setcmykcolor} def\n) jp
  470. (/i {setflat} def /J {setlinecap} def /j {setlinejoin} def\n) jp
  471. (/w {setlinewidth} def /M {setmiterlimit} def /d {setdash} def\n) jp
  472. (/u {gsave} def /U {grestore} def /K {k} def\n) jp
  473. (/N {newpath} def /n {closepath N} def\n) jp
  474. (/g {setgray} def /G {g} def\n) jp
  475. (/x {pop pop k} def /X {x} def\n) jp
  476. (/H {} def /h {H closepath} def /D {pop} def\n) jp
  477. (/*u { /N {/spth 0 def}def /S{/spth 1 def}def /F {/spth 2 def} def} def\n) jp
  478. (/*U { spth 0 eq {newpath} if spth 1 eq {stroke} if spth 2 eq {fill} if\n) jp
  479. (     /N {newpath} def /S {stroke} def /F {fill} def  } def\n) jp
  480. %(\n) jp
  481. jtxt3 {
  482.  (/TC {pop pop pop} def /Tr {pop} def\n) jp
  483.  (/To {pop gsave} def /TO {grestore} def\n) jp
  484.  (/Tp {pop matrix astore concat} def  /TP {0 0 moveto} def\n) jp
  485.  (/a_str 40 string def /cnt 0 def /h_str (X) def /undsc (_) 0 get def\n) jp
  486.  (/fntfix {a_str cvs dup length 1 sub /f_str exch string def\n) jp
  487.  (  {dup undsc eq {pop}{f_str cnt 3 -1 roll put /cnt cnt 1 add def\n) jp
  488.  (  } ifelse } forall flush /cnt 0 def f_str cvn } bind def\n) jp
  489.  
  490.  (/Tf {exch fntfix findfont exch scalefont setfont} def /Tx {show} def\n) jp
  491. }{
  492.  (/z {pop pop pop exch findfont exch scalefont setfont} def\n) jp
  493.  (/e {concat 0 0 m} def /t {show} def /T {} def\n) jp
  494. } ifelse
  495. (\n) jp
  496. jtxt3 {
  497.  (userdict /Adobe_packedarray 2 dict dup begin put\n) jp
  498.  (/initialize {} def /terminate {} def\n) jp
  499.  (userdict /Adobe_cmykcolor 2 dict dup begin put\n) jp
  500.  (/initialize {} def /terminate {} def\n) jp
  501.  (userdict /Adobe_cshow 2 dict dup begin put\n) jp
  502.  (/initialize {} def /terminate {} def\n) jp
  503.  (userdict /Adobe_customcolor 2 dict dup begin put\n) jp
  504.  (/initialize {} def /terminate {} def\n) jp
  505.  (userdict /Adobe_typography_AI3 2 dict dup begin put\n) jp
  506.  (/initialize {} def /terminate {} def\n) jp
  507.  (userdict /Adobe_IllustratorA_AI3 2 dict dup begin put\n) jp
  508.  (/initialize {} def /terminate {} def\n) jp
  509. }{
  510.  (userdict /Adobe_packedarray 2 dict dup begin put\n) jp
  511.  (/initialize {} def /terminate {} def\n) jp
  512.  (userdict /Adobe_cmykcolor 2 dict dup begin put\n) jp
  513.  (/initialize {} def /terminate {} def\n) jp
  514.  (userdict /Adobe_cshow 2 dict dup begin put\n) jp
  515.  (/initialize {} def /terminate {} def\n) jp
  516.  (userdict /Adobe_customcolor 2 dict dup begin put\n) jp
  517.  (/initialize {} def /terminate {} def\n) jp
  518.  (userdict /Adobe_Illustrator881 2 dict dup begin put\n) jp
  519.  (/initialize {} def /terminate {} def\n) jp
  520. } ifelse
  521. (%%EndProlog\n) jp
  522. (%%BeginSetup\n) jp
  523. jtxt3 {
  524.  (Adobe_packedarray /initialize get exec\n) jp
  525.  (Adobe_cmykcolor /initialize get exec\n) jp
  526.  (Adobe_cshow /initialize get exec\n) jp
  527.  (Adobe_customcolor /initialize get exec\n) jp
  528.  (Adobe_typography_AI3 /initialize get exec\n) jp
  529.  (Adobe_IllustratorA_AI3 /initialize get exec\n) jp
  530. }{
  531.  (Adobe_packedarray /initialize get exec\n) jp
  532.  (Adobe_cmykcolor /initialize get exec\n) jp
  533.  (Adobe_cshow /initialize get exec\n) jp
  534.  (Adobe_customcolor /initialize get exec\n) jp
  535.  (Adobe_Illustrator881 /initialize get exec\n) jp
  536. } ifelse
  537. (%%EndSetup\n) jp
  538. 0 0 0 1 oldsetcmykcolor
  539. currentstate
  540. jout {(%%Note: Load Postscript file to be converted now\n) print} if
  541.  
  542.